package com.atguigu.day16.work;

import java.util.Arrays;

public class Work6 {
    public static void main(String[] args) {
        int[] arr={0,1,2,3,4,5,6,7,8,9};
        int m=10;
        for (int i = 0; i < m; i++) {
            move(arr);
            System.out.println(Arrays.toString(arr));
        }
        int value=5;
        System.out.println(indexOf(arr,m,value));
    }
    public static int indexOf(int[] arr,int m,int value){
        while (m>arr.length){
            m=m-arr.length;
        }
        if (value==arr[0]){
            return 0;
        }else if (value>arr[0]){
            return Arrays.binarySearch(arr,1,m,value);
        }else{
            return Arrays.binarySearch(arr,m,arr.length,value);
        }
    }
    public static void move(int[] arr){
        int temp=arr[arr.length-1];
        System.arraycopy(arr,0,arr,1,arr.length-1);
        arr[0]=temp;
    }
}
